package com.lingnan.blog.utils;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * 获取访问当前路径的用户ip
 *
 * @author HeGuanChao
 */
public class IpUtil {

    public static String getHostAddress() throws UnknownHostException {
        InetAddress inetAddress = InetAddress.getLocalHost();
        // 获得IP地址字符串
        return inetAddress.getHostAddress();
    }

    /*public static void main(String[] args) throws UnknownHostException {
        String hostAddress = getHostAddress();
        System.out.println("hostAddress = " + hostAddress);
    }*/
}
